package org.aeon.colorfulplanebattle.flying.entity;

import java.awt.*;
import java.awt.image.BufferedImage;

/**
 * @author: MissingAeon
 * @date: 2024/1/9 10:01
 * @description:
 */
public abstract class Ship extends FlyObject {
    protected BufferedImage picture; // 图片
    protected boolean isShooting = false;
    protected int maxHp;
    protected int hp;
    protected int bulletSpeed;

    /**
     * 只允许继承使用
     *
     * @param camp 阵营
     */
    protected Ship(int camp) {
        super();
        this.camp = camp;
    }

    public boolean attack() {
        return this.isShooting = true;
    }

    @Override
    public void draw(Graphics g) {
        g.drawImage(picture, x, y, width, height, null);
        g.setColor(Color.red);
        g.drawRect(x + (width - touchWidth) / 2, y + (height - touchHeight) / 2, touchWidth, touchHeight);
    }


    public boolean isShooting() {
        final boolean copy = isShooting;
        isShooting = false;
        return copy;
    }

    public int getMaxHp() {
        return maxHp;
    }

    public int getHp() {
        return hp;
    }

    public int getBulletSpeed() {
        return bulletSpeed;
    }

    public void setBulletSpeed(int bulletSpeed) {
        this.bulletSpeed = bulletSpeed;
    }

    /**
     * 受伤
     */
    public void injury() {
        if (--hp <= 0) {
            this.setDestroy(true);
        }
    }

    public abstract void change();
}
